def binary_search(A,x):
    low=0
    high=len(A)-1
    while low< high:
        mid=(low+high)//2
        if A[mid]==x:
            return mid
        elif A[mid]>x:#[low mid-1][mid+1,high]
            high=mid-1
        else:
            low=mid+1
    if A[low]==x:
        return low
    else:
        return None

if __name__=='__main__':
    A=[1,2,3,6,11,17,25,99,136,335]
    x=99
    print 'A', A
    print 'search 99:', binary_search(A,99)
